/**
 * 组件的初始数据
 */
Component({

  properties: {
    list: {
      type: Array,
      value: [],
      observer: function (newVal, oldVal) {
        // 监听 parentData 的变化，并做出响应
        console.log('数据已更新：', newVal);
      }
    },
  },
  data: {
    list: [],
    hiddenmodalput: true,
  },

  /**
   * 组件的方法列表
   */
  //点击高级查询打开弹框
  methods: {
    opSearch() {
      this.setData({
        hiddenmodalput: false,
        list: this.properties.list
      });

    },
    bindInputChange(e) {


      this.data.list[e.target.dataset.index].value = e.detail.value
      this.setData({
        list: this.data.list
      })
    },
    pickerChange(e) {
      console.log(e)
      this.data.list[e.target.dataset.index].value = this.data.list[e.target.dataset.index].list[e.detail.value].value
      this.data.list[e.target.dataset.index].label = this.data.list[e.target.dataset.index].list[e.detail.value].name
      this.setData({
        list: this.data.list
      })
    },
    //重置弹框
    cancel: function (e) {
      this.data.list.forEach(item => {
        item.value = ''
        item.label = ''
      });
      this.setData({
        list: this.data.list
      });
    },
    //提交
    confirm: function (e) {
      this.setData({
        hiddenmodalput: true,
      });
      let searchObj = {}
      this.data.list.forEach(item => {
        searchObj[item.key] = item.value
      })
      this.triggerEvent('searchChange', searchObj);
    },

  }

})